//
//  ClassClusterTest.m
//  MacTestProject
//
//  Created by LiuLichen on 2022/4/14.
//

#import "ClassClusterTest.h"

@implementation EOCEmployee

+ (EOCEmployee*) employeeWithType: (EOCEmployeeType)type {
    switch (type) {
        case EOCEmployeeTypeDeveloper:
            return [EOCEmployeeDeveloper new];
        case EOCEmployeeTypeDesigner:
            return [EOCEmployeeDesigner new];
        case EOCEmployeeTypeFinance:
            return [EOCEmployeeFinance new];
        default:
            return [EOCEmployee new];
    }
}

- (void) doADaysWork {
    // Subclass implement this.
    NSLog(@"do a day work");
}

@end

@implementation EOCEmployeeDeveloper

- (void) doADaysWork {
    NSLog(@"write code");
}

@end

@implementation EOCEmployeeDesigner

- (void) doADaysWork {
    NSLog(@"paint image");
}

@end

@implementation EOCEmployeeFinance

- (void) doADaysWork {
    NSLog(@"caculate salary");
}

@end

@implementation ClassClusterTest

- (id) init {
    self = [super init];

    EOCEmployee* e1 = [EOCEmployee employeeWithType: EOCEmployeeTypeDeveloper];
    [e1 doADaysWork];
    EOCEmployee* e2 = [EOCEmployee employeeWithType: EOCEmployeeTypeDesigner];
    [e2 doADaysWork];
    EOCEmployee* e3 = [EOCEmployee employeeWithType: EOCEmployeeTypeFinance];
    [e3 doADaysWork];
    EOCEmployee* e4 = [EOCEmployee employeeWithType: EOCEmployeeTypeDefault];
    [e4 doADaysWork];

    return self;
}

@end
